﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Ryder_US_Website.BUS;
using Ryder_US_Website.Utils;

namespace Ryder_US_Website.Presentation.Admin
{
    public partial class Service_Insert : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["RUS_User"] == null)
            {
                Response.Redirect("Login.aspx");
            }
        }

        protected void btnHuy_Click(object sender, EventArgs e)
        {
            Response.Redirect("Service_List.aspx");
        }
        protected void Clean()
        {
            txtTenDichVu.Text = "";
            txtMoTa.Text = "";
        }
        protected void btnLamLai_Click(object sender, EventArgs e)
        {
            Clean();
        }

        protected void btnThem_Click(object sender, EventArgs e)
        {
            RUS_Service srv = new RUS_Service();
            srv.Service_name = txtTenDichVu.Text;
            srv.Service_description = txtMoTa.Text;
            try
            {
                srv = ServiceBUS.Insert(srv.Service_name, srv.Service_description);
            }
            catch (Exception ex)
            {
                Response.Write(UtilHelpers.ShowMessage(ex.Message));
            }
            if(txtTenDichVu.Text!="")
            {
                Response.Write(UtilHelpers.ShowMessage("Thêm dịch vụ thành công"));
                Response.Redirect("Service_List.aspx");
            }
            else
            {
                Response.Write(UtilHelpers.ShowMessage("Thêm dịch vụ thất bại."));
            }

        }
    }
}
